Skip to content

Conversation

@brettshearer
Copy link

Only load V8 rules for lower than 9 SDK (as this SDK already loads it by default, causing duplicate loads)

<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<ItemGroup Condition="'$(TargetFramework)' != ''">
<!-- Disable for SDK 9 and above -->
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globals.json currently pegs the SDK to 8.0.300. Visual Studio seems to ignore this though and use whatever SDK it comes with, but that only affects when WTG.Analyzers is built directly in VS and not when built with dotnet. None of this will have any effect on the consumers of WTG.Analyzers.

I assume you are trying to address the warning produced when the SDK provides a later version of the analyzer package. This approach means the analyzer package is silently dropped when the SDK version is updated past that point. I think a better solution would be to replace this package reference with EnableNETAnalyzers, then it will use whatever version the SDK provides without having to be separately updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnableNETAnalyzers is enabled by default in all supported SDKs by now, so we can probably just drop this entirely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't sound like the way they operate, are you sure it isn't set based on target framework?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you're right, it's net5.0 or higher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants